Skip to content

feat: Enables Nullable Reference Types#401

Merged
BenjaminMichaelis merged 7 commits intomainfrom
bmichaelis/nullability
Mar 10, 2026
Merged

feat: Enables Nullable Reference Types#401
BenjaminMichaelis merged 7 commits intomainfrom
bmichaelis/nullability

Conversation

@BenjaminMichaelis
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings February 24, 2026 09:10
@BenjaminMichaelis BenjaminMichaelis self-assigned this Feb 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables Nullable Reference Types (NRT) across the entire IntelliTect.Analyzer codebase by adding <Nullable>enable</Nullable> to Directory.Build.props and updating all affected code to properly handle nullable annotations. The changes ensure type safety by explicitly marking nullable types and adding appropriate null checks throughout the codebase.

Changes:

  • Enabled nullable reference types in Directory.Build.props for all projects
  • Updated analyzers with nullable annotations and null safety checks
  • Enhanced code fixes with proper nullable handling and graceful degradation patterns
  • Improved test infrastructure with nullable annotations and ArgumentNullException.ThrowIfNull validation

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Directory.Build.props Added <Nullable>enable</Nullable> to enable nullable reference types project-wide
UnusedLocalVariable.cs Added null check for DataFlowAnalysis result from AnalyzeDataFlow
BanImplicitDateTimeToDateTimeOffsetConversion.cs Added nullable annotation to GetTypeByMetadataName result
AttributesOnSeparateLines.cs (Analyzer) Added null checks for ApplicationSyntaxReference and null-conditional operator for AttributeClass.Name
AsyncVoid.cs (Analyzer) Improved pattern matching using is not pattern for cleaner null handling
AnalyzerBlockMixins.cs Updated return types and intermediate variables with nullable annotations
DiagnosticVerifier.cs Added nullable annotations and ArgumentNullException.ThrowIfNull validation
CodeFixVerifier.cs Added nullable annotations, ArgumentNullException.ThrowIfNull, and null-forgiving operators on Task.Result
DiagnosticVerifier.Helper.cs Added null checks with InvalidOperationException for compilation operations
CodeFixVerifier.Helper.cs Added null checks with InvalidOperationException for document and semantic model operations
AnalyzerTests.cs Added null check for compilation result
NamingIdentifierPascal.cs Added graceful degradation by returning original solution when null checks fail
NamingFieldPascalUnderscore.cs Added graceful degradation by returning original solution when null checks fail
AttributesOnSeparateLines.cs (CodeFix) Added null checks for syntax root and null-forgiving operators for Parent navigation
AsyncVoid.cs (CodeFix) Added null checks for syntax root and method declaration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Enables Nullable Reference Types throughout the project.

Adds null checks and throws exceptions where syntax root or semantic model retrieval fails, improving code safety and preventing potential null reference exceptions.
@BenjaminMichaelis
Copy link
Member Author

@copilot fix any code comments/issues that you find from this pr review

Copy link
Contributor

Copilot AI commented Mar 9, 2026

@BenjaminMichaelis I've opened a new pull request, #406, to work on those changes. Once the pull request is ready, I'll request review from you.

BenjaminMichaelis and others added 6 commits March 9, 2026 16:48
…onversion

AnalyzeObjectCreation now uses null-check and returns early instead of throwing
InvalidOperationException, consistent with AnalyzeInvocation null handling.
- SymbolMixins: INamedTypeSymbol -> INamedTypeSymbol? for GetTypeByMetadataName result
- FavorDirectoryEnumerationCalls code fix: nullable-annotate root, invocation,
  semanticModel, oldRoot, parent, returnType, and IParameterSymbol? targetParam
- DiagnosticVerifier.Helper: MetadataReference? field/return type and string? runtimeDir
GetTypeByMetadataName can return null if the type is not in the compilation.
Previously the nullable result was passed directly to SymbolEqualityComparer,
silently producing a wrong result. Now returns early, consistent with
AnalyzeObjectCreation.
Add test coverage for DateTime? compared against DateTimeOffset and
DateTimeOffset? in binary comparison expressions, which were previously
untested edge cases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BenjaminMichaelis BenjaminMichaelis merged commit 63a4b11 into main Mar 10, 2026
3 checks passed
@BenjaminMichaelis BenjaminMichaelis deleted the bmichaelis/nullability branch March 10, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants